package com.xiaohao.communication.controller;

import com.xiaohao.communication.bean.GoldCoin;
import com.xiaohao.communication.service.UserGoldCoinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserGoldCoinCotroller {

    @Autowired
    UserGoldCoinService userGoldCoinService;

    // 查询金币
    @ResponseBody
    @GetMapping("get-coin")
    public GoldCoin getUserGoldCoin(int id){
        GoldCoin usergoldCoin = userGoldCoinService.getUsergoldCoin(id);
        return usergoldCoin;
    }


    /*
    * 增加用户金币的数量  success
    * */
    @ResponseBody
    @GetMapping("/add-coin")
    public String addUserGoldCoin(GoldCoin goldCoin){
        userGoldCoinService.addUserGoldCoin(goldCoin);
        return "增加success";
    }


    /*
     * 减少用户金币的数量    success
     * */
    @ResponseBody
    @GetMapping("/reduce-coin")
    public String reduceUserGoldCoin(GoldCoin goldCoin){
        userGoldCoinService.reduceUserGoldCoin(goldCoin);
        return "减少success";
    }



}
